package com.yan.service.criteria.query;

public class OrderBy implements Comparable {
    /**
     * 数据库字段
     */
    private String sqlColumn;

    private Mark mark;

    private int sort;

    public OrderBy(String sqlColumn, Mark mark) {
        this.sqlColumn = sqlColumn;
        this.mark = mark;
    }

    public OrderBy(String sqlColumn, Mark mark, int sort) {
        this(sqlColumn, mark);
        this.sort = sort;
    }

    @Override
    public int compareTo(Object o) {
        if (o instanceof OrderBy) {
            return this.sort - ((OrderBy) o).getSort();
        }
        return -1;
    }

    public enum Mark {
        //无序
        empty(),
        //顺序
        asc(),
        //倒序
        desc();
    }

    public String getSqlColumn() {
        return sqlColumn;
    }

    public void setSqlColumn(String sqlColumn) {
        this.sqlColumn = sqlColumn;
    }

    public Mark getMark() {
        return mark;
    }

    public void setMark(Mark mark) {
        this.mark = mark;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }
}
